#pragma once

#ifndef DB_WRAPPER_H
#define DB_WRAPPER_H

#ifdef _WIN32
// Windows使用MySQL C++接口
namespace sql
{
    class Connection;
    class Statement;
    class PreparedStatement;
}
#endif

class DBWrapper
{
public:
    struct Config
    {
        std::string host;
        int port;
        std::string user;
        std::string password;
        std::string database;
    };

    DBWrapper(const Config &config);
    ~DBWrapper();

    bool connect();
    bool execute(const std::string &query);
    bool prepareAndExecute(const std::string &query,
                           const std::vector<std::string> &params);
    bool isConnected() const;

#ifdef _WIN32
    std::unique_ptr<sql::Connection> getNativeConnection();
#else
    MYSQL *getNativeConnection();
#endif

private:
    Config config_;
#ifdef _WIN32
    std::unique_ptr<sql::Connection> conn_;
#else
    MYSQL *conn_;
#endif
};

#endif
